<?php

class Bootstrap extends Yaf_Bootstrap_Abstract
{
    public function _initRoute(Yaf_Dispatcher $dispatcher) {
        $config = new Yaf_Config_ini(APP_PATH . '/conf/application.ini', 'common');

        $router = Yaf_Dispatcher::getInstance()->getRouter();
        $router->addConfig($config->routes);
        //异常捕获
        Yaf_Dispatcher::getInstance()->catchException(true);
//        var_dump($router->addConfig($config->routes));
    }

    public function _initDatabase() {
         
        $config = new Yaf_Config_ini(APP_PATH . '/conf/application.ini', 'common');
         
        $option = [
        'database_type' => 'mysql',
        'database_name' => $config->database->database_name,
        'server' => $config->database->server,
        'username' => $config->database->username,
        'password' => $config->database->password,
        'prefix' => '',
        'logging' =>'',
        'charset' => 'utf8'
        ];
        Yaf_Registry::set('db', new \Medoo\Medoo($option));
    }

    /**
    //初始化smarty视图引擎
    public function _initSmarty(Yaf_Dispatcher $dispatcher) {
        Yaf_Dispatcher::getInstance()->disableView(); //关闭其自动渲染

        Yaf_Loader::import( APP_PATH ."/application/library/smarty/libs/Adapter.php");
        $smarty = new Smarty_Adapter(null, Yaf_Application::app()->getConfig()->smarty);
        Yaf_Dispatcher::getInstance()->setView($smarty);

    }*/


}